package com.crazypos.controller;

import com.crazypos.common.ApiRestResponse;
import com.crazypos.pojo.bo.OrganizationCreateBO;
import com.crazypos.service.IOrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/organization")
public class OrganizationController {

    @Autowired
    private IOrganizationService organizationService;

    @PostMapping("/create")
    @PreAuthorize("hasRole('ADMIN')")
    public ApiRestResponse createOrganization(@RequestBody @Validated OrganizationCreateBO organizationCreateBO) {
        organizationService.createorganization(organizationCreateBO);
        return ApiRestResponse.success();
    }

    public ApiRestResponse getAllGanization() {
        return ApiRestResponse.success();
    }

}
